﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Radar.Optimization;
using Jage.Utils;

namespace Radar.Navigation
{
    internal class NavMeshFactory
        : SingletonBase<NavMeshFactory>
    {

        public NavMesh CreateNavMesh(NavMeshDefinition definition, GridDefinition gridDefinition)
        {
                var navMesh = new NavMesh();
                navMesh.Zones = NavZoneFactory.Instance.CreateNavZones(definition.Zones).ToArray();
                navMesh.Grid = GridFactory.Instance.CreateGrid(navMesh.Zones, gridDefinition.Width, gridDefinition.Height);
                LinkDetector.Instance.DetectAndAssignLinksAndWaypoints(navMesh);
                WaypointConnector.Instance.ConnectWaypoints(navMesh);
                return navMesh;
        }

    }

}